#!/usr/bin/perl

use CGI qw(:standard);
use XML::RSS;
use LWP::Simple qw(get);

my $numero_elementos = param('num_noticias');

#Baja  fichero
my $rdf = get('http://www.ideal.es/granada/rss/feeds/granada.xml');
my $rss = new XML::RSS;
$rss->parse($rdf);
my $rss_salida = new XML::RSS;
$rss_salida->channel( title => 'Noticias del día',
                      link => 'http://ideal.es',
                      description => 'Selección de noticias ' );
print header( -type => 'application/xhtml+xml' );

for (my $i = 0; $i < $numero_elementos;$i ++ ) {
  $rss_salida->add_item( title => $rss->{'items'}[$i]->{'title'},
                         link => $rss->{'items'}[$i]->{'link'} );
}
print $rss_salida->as_string;
